package com.iris.live.services.data.models;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.List;

/**
 * Created by Xin on 8/11/2016.
 */
@SuppressWarnings("JpaDataSourceORMInspection")
@Entity
@Table(name = "LSH导入名单联系表", schema = "sg_lsh", catalog = "")
public class Lsh导入名单联系表Model {
    private Integer 联系记录编号;
    private String 许可;
    private Integer 导入编号;
    private String 备注;
    private String 更新账号;
    private Timestamp 更新时间;
    private List<Lsh活动表Model> lsh活动表ModelList;

    @ManyToMany(fetch = FetchType.EAGER) @Fetch(FetchMode.SELECT)
    @JoinTable(name = "LSH导入名单联系附属",
            joinColumns = {
                    @JoinColumn(name = "联系记录编号", referencedColumnName = "联系记录编号")
            },
            inverseJoinColumns = {
                    @JoinColumn(name = "活动编号", referencedColumnName = "活动编号")
            }
    )
    @JsonProperty("活动")
    public List<Lsh活动表Model> getLsh活动表ModelList() {
        return lsh活动表ModelList;
    }

    public void setLsh活动表ModelList(List<Lsh活动表Model> lsh活动表ModelList) {
        this.lsh活动表ModelList = lsh活动表ModelList;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "联系记录编号")
    public Integer get联系记录编号() {
        return 联系记录编号;
    }

    public void set联系记录编号(Integer 联系记录编号) {
        this.联系记录编号 = 联系记录编号;
    }

    @Basic
    @Column(name = "许可")
    public String get许可() {
        return 许可;
    }

    public void set许可(String 许可) {
        this.许可 = 许可;
    }

    @Basic
    @Column(name = "导入编号")
    public Integer get导入编号() {
        return 导入编号;
    }

    public void set导入编号(Integer 导入编号) {
        this.导入编号 = 导入编号;
    }

    @Basic
    @Column(name = "备注")
    public String get备注() {
        return 备注;
    }

    public void set备注(String 备注) {
        this.备注 = 备注;
    }

    @Basic
    @Column(name = "更新账号")
    public String get更新账号() {
        return 更新账号;
    }

    public void set更新账号(String 更新账号) {
        this.更新账号 = 更新账号;
    }

    @Basic
    @Column(name = "更新时间")
    public Timestamp get更新时间() {
        return 更新时间;
    }

    public void set更新时间(Timestamp 更新时间) {
        this.更新时间 = 更新时间;
    }

    @PrePersist
    @PreUpdate
    public void onPreUpdate() {
        this.set更新时间(new Timestamp(System.currentTimeMillis()));
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Lsh导入名单联系表Model that = (Lsh导入名单联系表Model) o;

        if (联系记录编号 != that.联系记录编号) return false;
        if (许可 != null ? !许可.equals(that.许可) : that.许可 != null) return false;
        if (导入编号 != null ? !导入编号.equals(that.导入编号) : that.导入编号 != null) return false;
        if (备注 != null ? !备注.equals(that.备注) : that.备注 != null) return false;
        if (更新账号 != null ? !更新账号.equals(that.更新账号) : that.更新账号 != null) return false;
        if (更新时间 != null ? !更新时间.equals(that.更新时间) : that.更新时间 != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = 联系记录编号;
        result = 31 * result + (许可 != null ? 许可.hashCode() : 0);
        result = 31 * result + (导入编号 != null ? 导入编号.hashCode() : 0);
        result = 31 * result + (备注 != null ? 备注.hashCode() : 0);
        result = 31 * result + (更新账号 != null ? 更新账号.hashCode() : 0);
        result = 31 * result + (更新时间 != null ? 更新时间.hashCode() : 0);
        return result;
    }
}
